package io.kiki.sba.registry.server.clientInterface.remoting.console.handler;

import io.kiki.sba.registry.api.Channel;
import io.kiki.sba.registry.common.model.GenericResponse;
import io.kiki.sba.registry.common.model.sessionserver.ClientManagerQueryRequest;
import io.kiki.sba.registry.common.model.sessionserver.ClientManagerResp;
import io.kiki.sba.registry.server.clientInterface.providedata.FetchClientOffAddressService;

import javax.annotation.Resource;
import java.util.Set;


public class GetClientManagerRequestHandler extends AbstractConsoleHandler<ClientManagerQueryRequest> {

    @Resource
    private FetchClientOffAddressService fetchClientOffAddressService;

    @Override
    public GenericResponse<ClientManagerResp> doHandle(Channel channel, ClientManagerQueryRequest request) {
        Set<String> clientOffAddress = fetchClientOffAddressService.getClientOffAddress();
        return new GenericResponse<ClientManagerResp>().fillSucceed(new ClientManagerResp(true, clientOffAddress));
    }

    @Override
    public Class interest() {
        return ClientManagerQueryRequest.class;
    }

    @Override
    public Object buildFailedResponse(String msg) {
        return new GenericResponse<ClientManagerResp>().fillFailed(msg);
    }
}
